package com.yzt.zhuju.dialog;

import android.os.Bundle;
import android.view.Gravity;

import com.yzt.p_base.utils.KeyboardUtils;
import com.yzt.p_base.utils.SharedPreferenceUtil;
import com.yzt.zhuju.R;
import com.yzt.zhuju.constants.PreferenceConstant;

/**
 * author : bob
 * date   : 2022/12/1
 * desc   :
 */
public abstract class BottomBaseDialog extends BaseDialog {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, R.style.DialogBottomCustomStyle_1);
        keyboardHeight();
    }

    @Override
    public int getGravity() {
        return Gravity.BOTTOM;
    }

    public int keyHeight = 0;

    protected void keyboardHeight() {
        KeyboardUtils.registerSoftInputChangedListener(mActivity, height -> {
            mSoftInputHeight(height);
            if (height > keyHeight) {
                SharedPreferenceUtil.getInstance().putValue(PreferenceConstant.KEYBOARD_HEIGHT, height);
                keyHeight = height;
            }
        });
    }

    public void mSoftInputHeight(int height) {

    }
}

